package com.atguigu.gmall.order.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.biz.OrderBizService;
import com.atguigu.gmall.order.vo.OrderSubmitDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author lfy
 * @Description
 * @create 2023-08-02 9:54
 */
@RequestMapping("/api/order")
@RestController
public class OrderRestController {


    @Autowired
    OrderBizService orderBizService;


    /**
     * 提交订单请求
     * @param tradeNo
     * @param submitDataVo
     * @return
     */
    @PostMapping("/auth/submitOrder")
    public Result orderSubmit(@RequestParam("tradeNo") String tradeNo,
                              @RequestBody @Validated OrderSubmitDataVo submitDataVo){


        //TODO 保存订单，完成后返回订单Id即可
        Long orderId = orderBizService.submitOrder(tradeNo,submitDataVo);

        //前端接不了大数字
        return Result.ok(orderId.toString());
    }

}
